package com.ymatou.i.accounting.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymatou.i.accounting.api.parameter.AccountBean;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取资金账户接口Call
*FreeMaker Template自动生成代码
*/
public class GetAccountCall extends YmatouBaseCall{
	private static String opurl ="api/Account/GetAccount";
	
	public GetAccountCall() {
		super(EnvSetup.getSystemUrl("api_accounting"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	//get data
	public String getData(){
		String data=null;
		try {
			data = new JSONObject(getReturnData()).getString("Data");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return data;
		
	}
	
	//get the return account info
	public AccountBean getReturnAccount() throws JSONException{
		AccountBean account = null;
		String data = getData();
		if (data!=null){
			account = (AccountBean) FormatUtil.GSONToObject(data,
					AccountBean.class);
		}
		return account;
	}
	
	
	
	
	
	

}